package com.itheima.common;

public class BaseContext {

    private final static ThreadLocal<String> THREAD_LOCAL = new ThreadLocal<>();
    private final static ThreadLocal<Integer> USE_LOCAL = new ThreadLocal<>();

    /**
     * 设置登录用户id
     *
     * @param userId 用户id
     */
    public static void setLoginUserId(String userId) {
        THREAD_LOCAL.set(userId);
    }

    public static void setUserId(Integer userId) {
        USE_LOCAL.set(userId);
    }

    /**
     * 获得登录用户id
     *
     * @return {@link String}
     */
    public static String getLoginUserId() {
        return THREAD_LOCAL.get();
    }

    /**
     * 删除登录用户id
     */
    public static void removeLoginUserId() {
        THREAD_LOCAL.remove();
    }

    public static Integer getUserId() {
        return USE_LOCAL.get();
    }
}
